package com.woniuxy.commons.util;

public class RedisKeyUtil {
    
    //注册短信验证码key
    public static String registerCodeKey(String phone) throws Exception {
        return "register:code:phone:" + phone;
    }
    
    //一分钟是否发送过注册短信key
    public static String registerCodeOnMinute(String phone) throws Exception {
        return "register:code:minute:phone:" + phone;
    }
    
    //登录短信验证码key
    public static String loginCodeKey(String phone) throws Exception {
        return "login:code:phone:" + phone;
    }
    
    //一分钟是否发送过登录短信key
    public static String loginCodeOnMinute(String phone) throws Exception {
        return "login:code:minute:phone:" + phone;
    }
    
    //一小时内发送短信的总次数
    public static String sendNumbers(String phone) throws Exception {
        return "sendCode:number:phone:" + phone;
    }
    
    //某个用户的书籍收藏列表
    public static String collectBook(Integer userId) throws Exception {
        return "collect:book:userId:" + userId;
    }
    
    //书籍收藏排行榜
    public static String collectBookRank() throws Exception {
        return "collect:book:rank";
    }
    
    //图书类别树型数据缓存KEY
    public static String cacheBookTreeType() throws Exception {
        return "cache:bookType:tree";
    }
    
    //保存用户在平台中的购物车中的商品ID集合KEY
    public static String userShoppingCar(Integer userId) throws Exception {
        return "shopping:car:userId:" + userId;
    }
    
    //保存用户购物车某一条记录的详细信息KEY
    public static String shoppingCarInfo(Integer userId, Integer bookId) throws Exception {
        return "shopping:car:userId:" + userId + ":bookId:" + bookId;
    }
    
    //注册用户名锁
    public static String lockRegisterByUsername(String userName) throws Exception {
        return "lock:register:username:" + userName;
    }
    
    //注册电话锁
    public static String lockRegisterByUserPhone(String userPhone) throws Exception {
        return "lock:register:userPhone:" + userPhone;
    }
    
    //注册邮箱锁
    public static String lockRegisterByUserEmail(String userEmail) throws Exception {
        return "lock:register:userEmail:" + userEmail;
    }
    
    //下单锁
    public static String lockOrderGoodsId(Integer goodsId) throws Exception{
        return "lock:order:goodsId:" + goodsId;
    }
    
    //退款订单锁
    public static String lockOrderRefund(String orderId) throws Exception{
        return "lock:refund:orderId:" + orderId;
    }

    //
    /**
     * 订单支付限时
     */
    public static String payOrderTime(String orderId){
        return "payOrderTime:"+orderId;
    }
}

